package cn.liontalk.StrategyPattern;

/**
 * @author ZhouZhe
 * @version 1.0
 * @description 鸭子的抽象类 所有的鸭子都要继承此类，抽象了鸭子的显示和鸣叫
 * @date 2019-01-09 15:53
 **/
public abstract class Duck {


    private FlyingStrategy flyingStrategy;

    /**
     * 鸭子的叫声
     * 通用行为 由超类实现
     */
    public void quack() {
        System.out.println("嘎嘎嘎嘎");
    }


    /**
     * 显示鸭子的外观
     * 鸭子的外观各不相同，声明为abstract ,由子类实现
     */
    public abstract void display();


    public void setFlyingStrategy(FlyingStrategy flyingStrategy) {
        this.flyingStrategy = flyingStrategy;
    }


    public void fly() {
        flyingStrategy.performFly();
    }
}
